package Demo1;

public class Triangle {
    private int a;
    private int b;
    private int c;

    private boolean ifATriangle(){
       if(a+b>c&&a+c>b&&b+c>a){
           return true;
       }
       return false;
    }
    private void testPerimeter(){
         int perimeter=a+b+c;
        System.out.println("perimeter="+perimeter);
    }
    private void testArea(){
         int s=(a+b+c)/2;
         double area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
        System.out.println("area="+area);
    }

    public static void main(String[] args) {
        Triangle triangle =new Triangle();
        triangle.a=3;
        triangle.b=4;
        triangle.c=5;
        boolean flag=triangle.ifATriangle();
        if(flag){
            triangle.testPerimeter();
            triangle.testArea();
        }else{
            System.out.println("不构成三角形");
        }
    }
}
